var ctx;
var cellId;
var label;
var pages = $("#pages").val();
var pSize;

function setCtx(ctx){
	this.ctx = ctx;
}

function gotoPage(page){
	label = ifNull($("#label").val());
	cellId = ifNull($("#cellId").val());
	pSize = ifNull($("#pSize").val());
	//解决ie9以下placeholder与value重复的问题
	if(label == $("#label").attr("placeholder")){
		label = "";
	}
	if(parseInt(page) < 1 ){
		//当页数小于1时，停留在第一页
		page = 1;
	}
	if(parseInt(page) > parseInt(pages)){
		//当页数大于总页数时，停留在最后一页
		page = pages;
	}
	loadContent("/commonConfig/infoListForCell?pNo="+ page +"&label="+ label+ "&cellId="+ cellId + "&pSize="+ pSize);
}

function gotoConfigPage(page) {
	if(page == null){
		page = $(".inputclass").val();
	}
	
	if(parseInt(page) < 1 ){
		//当页数小于1时，停留在第一页
		page = 1;
	}
	if(parseInt(page) > parseInt(pages)){
		//当页数大于总页数时，停留在最后一页
		page = pages;
	}
	label = ifNull($("#label").val());
	cellId = ifNull($("#cellId").val());
	pSize = ifNull($("#pSize").val());
	//解决ie9以下placeholder与value重复的问题
	if(label == $("#label").attr("placeholder")){
		label = "";
	}
	loadContent("/commonConfig/infoListForCell?pNo="+ page+"&label="+ label+ "&cellId="+ cellId + "&pSize="+ pSize);
}

function ifNull(mess){
	if(mess == null || mess == undefined){
		mess = "";
	}
	
	return mess;
}

//条件搜索菜单列表
function getInfoList(){
	label = ifNull($("#label").val());
	cellId = ifNull($("#cellId").val());
	pSize = ifNull($("#pSize").val());
	//解决ie9以下placeholder与value重复的问题
	if(label == $("#label").attr("placeholder")){
		label = "";
	}
	loadContent("/commonConfig/infoListForCell?pNo=1&label="+ label+ "&cellId="+ cellId + "&pSize="+ pSize);
	
}
/**
 * 小区详情
 */
function detailConfig(id){
	loadContent("/commonConfig/gotoDetailForCell?id="+id);
}

//编辑配置信息
function editConfig(id,editType) {
	loadContent("/commonConfig/editConfigForCell?id="+id+"&editType="+editType);
}

//鼠标滑入一行改变背景颜色
function mouseoverOne(target){
	 $(target).children().each(function(){
		  	    $(this).css("background","#D3F0F1");
		     });
}

//鼠标滑出一行恢复原来的背景颜色
function mouseoutOne(target){
	 $(target).children().each(function(){
	  	    $(this).css("background","");
	     });
}
//选择或取消选中当前记录，同时改变背景颜色
function selectOne(id,target){
    if(target.checked){    
        $("#btn" + id).attr("checked", true); 
       $(target).parents("tr").children().each(function(){
    	    $(this).css("background","#D3F0F1");
       });
       
    }else{    
        $("#btn" + id).attr("checked", false); 
        $(target).parents("tr").children().each(function(){
    	    $(this).css("background","");
       });
    } 
}
